package game;

import java.awt.image.PackedColorModel;

/**
 * 角色类
 */
public class Role {
    /**
     * 名称
     */
    private String name;
    /**
     * 等级
     */
    private int level = 1;
    /**
     * 体力
     */
    private int hp;
    /**
     * 攻击力
     */
    private int attackValue;
    /**
     * 防御力
     */
    private int defineValue;
    /**
     * 金币
     */
    private int coin;
    /**
     * 体力角色加权
     */
    private int hpWeight;
    /**
     * 攻击力角色加权
     */
    private int attackWeight;
    /**
     * 防御力角色加权
     */
    private int defineWeight;
    /**
     * 体力的上限值
     */
    private int maxHp;

    /**
     * 自我介绍
     */
    public void intro(){
        System.out.println("我是"+this.name
                            +"\n等级："+this.level
                            +"\n体力值："+this.hp
                            +"\n攻击力："+this.attackValue
                            +"\n防御力："+this.defineValue
                            +"\n金币："+this.coin);
    }

    public Role() {
    }

    public Role(String name, int level) {
        this.name = name;
        this.level = level;

    }

    /**
     * 初始化体力、攻击力、防御力
     */
    public void init(){
        this.hp = this.level * this.hpWeight;
        this.attackValue = this.level * this.attackWeight;
        this.defineValue = this.level * this.defineWeight;
        this.maxHp = this.hp;
    }
    /**
     * 攻击盗贼的方法
     * @param thieves 盗贼对象
     */
    public void attack(Thieves thieves){
        System.out.println(this.name+"对"+thieves.getName()+"造成");
        thieves.changeHp(this.attackValue);

    }

    /**
     * 防御方法
     * @param attackValue
     * @return
     */
    private int define(int attackValue){
        System.out.println(this.name+"防御"+this.defineValue+"的伤害");
        if(this.defineValue > attackValue){
            System.out.println("没有造成任何伤害");
        }else{
            return attackValue - this.defineValue;
        }
        return 0;
    }

    /**
     * 攻击减血的方法
     * @param hp
     */
    public void changeHp(int hp){
        hp = this.define(hp);
        this.hp -= hp;
        System.out.println(hp + "点的伤害");
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getLevel() {
        return level;
    }

    public void setLevel(int level) {
        this.level = level;
        init();

    }

    public int getHp() {
        return hp;
    }

    public void setHp(int hp) {
        this.hp = hp;
    }

    public int getAttackValue() {
        return attackValue;
    }

    public void setAttackValue(int attackValue) {
        this.attackValue = attackValue;
    }

    public int getDefineValue() {
        return defineValue;
    }

    public void setDefineValue(int defineValue) {
        this.defineValue = defineValue;
    }

    public int getCoin() {
        return coin;
    }

    public void setCoin(int coin) {
        this.coin = coin;
    }

    public int getHpWeight() {
        return hpWeight;
    }

    public void setHpWeight(int hpWeight) {
        this.hpWeight = hpWeight;
    }

    public int getAttackWeight() {
        return attackWeight;
    }

    public void setAttackWeight(int attackWeight) {
        this.attackWeight = attackWeight;
    }

    public int getDefineWeight() {
        return defineWeight;
    }

    public void setDefineWeight(int defineWeight) {
        this.defineWeight = defineWeight;
    }

    public int getMaxHp() {
        return maxHp;
    }

    public void setMaxHp(int maxHp) {
        this.maxHp = maxHp;
    }
}
